home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / tbasmhlp.arc / SOURCE.ARC / DRIVROOM.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-07-19  |  1.3 KB  |  48 lines

  1. ;FILE    :DRIVROOM
  2. ;PURPOSE:To find out room/storage info on any drive in system.
  3. ;USEAGE    :CALL DRVSPACE(drive%,free&,capacity&,free.per%)
  4. ;drive%= 0- Default 1-A: 2-B: .. etc.
  5. drivroom segment
  6. assume    cs:drivroom
  7.     push    bp    ;Saveit, as always
  8.     mov    bp,sp
  9.     les    di,[bp+12h]    ;Should be pointer to drive%
  10.     mov    dx,es:[di]    ;Okay.. we got the drive
  11.     mov    ah,036h        ;Tell'm we want free space par'ner.
  12.     int    021h        ;GO!
  13.     push    dx        ;Save clusters on drive.
  14.  
  15.                 ;Calculate free bytes.
  16.     mul    cx        ;CX(byte/sector) x AX(sectors/cluster)
  17.     push    ax        ;This is bytes/cluster, save it..
  18.     mul    bx        ;BX(available clusters) x AX(bytes/cluster)
  19.  
  20.                 ;Store it.
  21.     les    di,[bp+0eh]    ;Find where our number is located
  22.     mov    es:[di],ax    ;lowest bytes
  23.     mov    es:[di+2],dx    ;Highest bytes.
  24.  
  25.                 ;Let's calc total bytes to start with.
  26.     pop    ax        ;byte/cluster
  27.     pop    dx        ;clusters/drive
  28.     push    dx        ;save DX for % calc
  29.     mul    dx        ;Okay, total drive capacity
  30.                 ;Store it.
  31.     les    di,[bp+0ah]    ;Where variable is
  32.     mov    es:[di],ax    ;Lower 2 bytes
  33.     mov    es:[di+2],dx    ;Upper 2 bytes    
  34.  
  35.                 ;Calc % free from cluster count
  36.     pop    cx        ;Number of cluster on disk
  37.     mov     ax,100d        ;100%
  38.     mul    bx        ;Free clusters. x 100
  39.     div    cx        ;divide by clusters available
  40.  
  41.                 ;Store % result
  42.     les    di,[bp+06h]    ;Where % variable is
  43.     mov    es:[di],ax    ;% result
  44.  
  45.     pop    bp
  46. drivroom ends
  47.     end
  48.